package com.water.app.Config;

import com.water.app.Interceptor.ManagerInterceptor;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import com.water.app.Interceptor.LoginInterceptor;
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    @Resource
    StringRedisTemplate stringRedisTemplate;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor(stringRedisTemplate))
                .addPathPatterns("/**")
                .excludePathPatterns("/api/login/**", "/api/register/**","/api/forget/**",
                        "/api/manager/**","/api/isManager");
        registry.addInterceptor(new ManagerInterceptor(stringRedisTemplate))
                .addPathPatterns("/api/manager/**")
                .excludePathPatterns("/api/login/**", "/api/register/**","/api/forget/**","/api/isManager");
    }



}
